-
Notifications
You must be signed in to change notification settings - Fork 545
Fix filter var on uncertainty flags #4418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix filter var on uncertainty flags #4418
Conversation
| } | ||
|
|
||
| $type = $this->getFlagsValue($flagsType); | ||
| if (!$type instanceof ConstantIntegerType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In next PR I'll add support for union of ConstantIntegerType
| ['%s|false', ''], | ||
| ['%s|false', ', $mixed'], | ||
| ['%s|false', ', ["flags" => $mixed]'], | ||
| ['mixed', ', $mixed'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was wrong, with a mixed flag it's not necessary %s|false cause you might pass FILTER_NULL_ON_FAILURE or FILTER_FORCE_ARRAY or FILTER_REQUIRE_ARRAY
| ['%s|false', ', $mixed'], | ||
| ['%s|false', ', ["flags" => $mixed]'], | ||
| ['mixed', ', $mixed'], | ||
| ['mixed', ', ["flags" => $mixed]'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was wrong, with a mixed flag it's not necessary %s|false cause you might pass FILTER_NULL_ON_FAILURE or FILTER_FORCE_ARRAY or FILTER_REQUIRE_ARRAY
| ['mixed', ', $mixed'], | ||
| ['mixed', ', ["flags" => $mixed]'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was wrong, with a mixed flag it's not necessary bool cause you might pass FILTER_NULL_ON_FAILURE or FILTER_FORCE_ARRAY or FILTER_REQUIRE_ARRAY
| { | ||
| assertType('int', filter_var($int, FILTER_VALIDATE_INT)); | ||
| assertType('int|false', filter_var($int, FILTER_VALIDATE_INT, $options)); | ||
| assertType('mixed', filter_var($int, FILTER_VALIDATE_INT, $options)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was wrong, with a array $options, the flag might be mixed.
And with a mixed flag it's not necessary mixed cause you might pass FILTER_NULL_ON_FAILURE or FILTER_FORCE_ARRAY or FILTER_REQUIRE_ARRAY
|
This pull request has been marked as ready for review. |
48abefc to
32e8d95
Compare
|
Thank you! |
Closes phpstan/phpstan#11485